//
//  MYGAcademicDetailFooterView.swift
//  MYDoctor
//
//  Created by chenjs on 2024/6/1.
//

import UIKit
import QMUIKit

class MYGAcademicDetailFooterView: UITableViewCell {

    var watchBackButtonBlock:(()->Void)?
    var colloctButtonBlock:(()->Void)?
    
    var model : MYGAcademicDetailFooterCollectModel? {
        didSet {
            guard let item = model else {return}
            colloctButton.isHidden = item.isShow
            colloctButton.isSelected = item.isLike == 1
        }
    }
    
    // MARK: - init
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        selectionStyle = .none
        contentView.backgroundColor = .white
        configUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func configUI() {
        addSubview(backView)
//        backView.addSubview(watchBackButton)
        backView.addSubview(colloctButton)
        
        backView.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(20)
            make.top.bottom.equalToSuperview()
        }
        
//        watchBackButton.snp.makeConstraints { make in
//            make.left.equalTo(20)
//            make.bottom.equalToSuperview().inset(10)
//            make.height.equalTo(15)
//            make.width.equalTo(50)
//        }
        
        colloctButton.snp.makeConstraints { make in
            make.left.equalTo(20)
            make.bottom.equalToSuperview().inset(10)
            make.height.equalTo(15)
            make.width.equalTo(50)
        }
        
        backView.addBordorLine(top: false, right: true, bottom: true, left: true, color: UIColor.init(hexString: "f6f6f6"), width: 2)
//        backView.addCorner(radius: 5)
    }
    
    private lazy var backView:UIView = {
        let view = UIView()
        view.backgroundColor = .white
        return view
    }()
//    private lazy var watchBackButton:QMUIButton = {
//        let btn = QMUIButton()
//        btn.setImage(UIImage(named: "watchBack"), for: .normal)
//        btn.setTitle("回看", for: .normal)
//        btn.imagePosition = .left
//        btn.spacingBetweenImageAndTitle = 5
//        btn.titleLabel?.font = .regular(11)
//        btn.setTitleColor(.rgba(170, 170, 170, 1), for: .normal)
//        btn.addTarget(self, action: #selector(clickWatchBackButton), for: .touchUpInside)
//        return btn
//    }()
    
    private lazy var colloctButton:QMUIButton = {
        let btn = QMUIButton()
        btn.setImage(UIImage(named: "meet_collection"), for: .normal)
        btn.setImage(UIImage(named: "meet_collection_sel"), for: .selected)
        btn.setTitle("收藏", for: .normal)
        btn.imagePosition = .left
        btn.spacingBetweenImageAndTitle = 5
        btn.titleLabel?.font = .regular(11)
        btn.setTitleColor(.rgba(170, 170, 170, 1), for: .normal)
        btn.addTarget(self, action: #selector(clickColloctButton), for: .touchUpInside)

        return btn
    }()
    
    @objc func clickWatchBackButton(){
        watchBackButtonBlock?()
    }
    @objc func clickColloctButton(){
        colloctButtonBlock?()
    }
    
}
